+Thu Dec 3 06:20:59 1998 Tim Janik <timj@gtk.org>
+
+ * gtk/gtkwindow.c: moved checks upon focus setting from
+ gtk_window_real_set_focus to gtk_window_set_focus, so we don't
+ emit the signal if unneccessary.
+
+ * gtk/gtkwidget.c (gtk_widget_grab_focus): clear up the old focus
+ containers when grabbing focus on a new widget. this is based on
+ a patch from Alexis Mikhailov, submitted to gtk-list on 4 Nov 1998.
+
+ * gtk/gtkclist.c (gtk_clist_focus_out): set CLIST_CHILD_HAS_FOCUS
+ flag, so we take the buttons into consideration upon the next focus
+ request.
+
+ * gtk/gtkcontainer.c (gtk_container_set_focus_child): fixed an
+ assertment.
+
Wed Dec 2 17:45:21 CST 1998 Shawn T. Amundson <amundson@gtk.org>
* gtk/gtkpixmap.c: Fixes for low-color displays and a slight
+Thu Dec 3 06:20:59 1998 Tim Janik <timj@gtk.org>
+
+ * gtk/gtkwindow.c: moved checks upon focus setting from
+ gtk_window_real_set_focus to gtk_window_set_focus, so we don't
+ emit the signal if unneccessary.
+
+ * gtk/gtkwidget.c (gtk_widget_grab_focus): clear up the old focus
+ containers when grabbing focus on a new widget. this is based on
+ a patch from Alexis Mikhailov, submitted to gtk-list on 4 Nov 1998.
+
+ * gtk/gtkclist.c (gtk_clist_focus_out): set CLIST_CHILD_HAS_FOCUS
+ flag, so we take the buttons into consideration upon the next focus
+ request.
+
+ * gtk/gtkcontainer.c (gtk_container_set_focus_child): fixed an
+ assertment.
+
Wed Dec 2 17:45:21 CST 1998 Shawn T. Amundson <amundson@gtk.org>
* gtk/gtkpixmap.c: Fixes for low-color displays and a slight
+Thu Dec 3 06:20:59 1998 Tim Janik <timj@gtk.org>
+
+ * gtk/gtkwindow.c: moved checks upon focus setting from
+ gtk_window_real_set_focus to gtk_window_set_focus, so we don't
+ emit the signal if unneccessary.
+
+ * gtk/gtkwidget.c (gtk_widget_grab_focus): clear up the old focus
+ containers when grabbing focus on a new widget. this is based on
+ a patch from Alexis Mikhailov, submitted to gtk-list on 4 Nov 1998.
+
+ * gtk/gtkclist.c (gtk_clist_focus_out): set CLIST_CHILD_HAS_FOCUS
+ flag, so we take the buttons into consideration upon the next focus
+ request.
+
+ * gtk/gtkcontainer.c (gtk_container_set_focus_child): fixed an
+ assertment.
+
Wed Dec 2 17:45:21 CST 1998 Shawn T. Amundson <amundson@gtk.org>
* gtk/gtkpixmap.c: Fixes for low-color displays and a slight
+Thu Dec 3 06:20:59 1998 Tim Janik <timj@gtk.org>
+
+ * gtk/gtkwindow.c: moved checks upon focus setting from
+ gtk_window_real_set_focus to gtk_window_set_focus, so we don't
+ emit the signal if unneccessary.
+
+ * gtk/gtkwidget.c (gtk_widget_grab_focus): clear up the old focus
+ containers when grabbing focus on a new widget. this is based on
+ a patch from Alexis Mikhailov, submitted to gtk-list on 4 Nov 1998.
+
+ * gtk/gtkclist.c (gtk_clist_focus_out): set CLIST_CHILD_HAS_FOCUS
+ flag, so we take the buttons into consideration upon the next focus
+ request.
+
+ * gtk/gtkcontainer.c (gtk_container_set_focus_child): fixed an
+ assertment.
+
Wed Dec 2 17:45:21 CST 1998 Shawn T. Amundson <amundson@gtk.org>
* gtk/gtkpixmap.c: Fixes for low-color displays and a slight
+Thu Dec 3 06:20:59 1998 Tim Janik <timj@gtk.org>
+
+ * gtk/gtkwindow.c: moved checks upon focus setting from
+ gtk_window_real_set_focus to gtk_window_set_focus, so we don't
+ emit the signal if unneccessary.
+
+ * gtk/gtkwidget.c (gtk_widget_grab_focus): clear up the old focus
+ containers when grabbing focus on a new widget. this is based on
+ a patch from Alexis Mikhailov, submitted to gtk-list on 4 Nov 1998.
+
+ * gtk/gtkclist.c (gtk_clist_focus_out): set CLIST_CHILD_HAS_FOCUS
+ flag, so we take the buttons into consideration upon the next focus
+ request.
+
+ * gtk/gtkcontainer.c (gtk_container_set_focus_child): fixed an
+ assertment.
+
Wed Dec 2 17:45:21 CST 1998 Shawn T. Amundson <amundson@gtk.org>
* gtk/gtkpixmap.c: Fixes for low-color displays and a slight
+Thu Dec 3 06:20:59 1998 Tim Janik <timj@gtk.org>
+
+ * gtk/gtkwindow.c: moved checks upon focus setting from
+ gtk_window_real_set_focus to gtk_window_set_focus, so we don't
+ emit the signal if unneccessary.
+
+ * gtk/gtkwidget.c (gtk_widget_grab_focus): clear up the old focus
+ containers when grabbing focus on a new widget. this is based on
+ a patch from Alexis Mikhailov, submitted to gtk-list on 4 Nov 1998.
+
+ * gtk/gtkclist.c (gtk_clist_focus_out): set CLIST_CHILD_HAS_FOCUS
+ flag, so we take the buttons into consideration upon the next focus
+ request.
+
+ * gtk/gtkcontainer.c (gtk_container_set_focus_child): fixed an
+ assertment.
+
Wed Dec 2 17:45:21 CST 1998 Shawn T. Amundson <amundson@gtk.org>
* gtk/gtkpixmap.c: Fixes for low-color displays and a slight
+Thu Dec 3 06:20:59 1998 Tim Janik <timj@gtk.org>
+
+ * gtk/gtkwindow.c: moved checks upon focus setting from
+ gtk_window_real_set_focus to gtk_window_set_focus, so we don't
+ emit the signal if unneccessary.
+
+ * gtk/gtkwidget.c (gtk_widget_grab_focus): clear up the old focus
+ containers when grabbing focus on a new widget. this is based on
+ a patch from Alexis Mikhailov, submitted to gtk-list on 4 Nov 1998.
+
+ * gtk/gtkclist.c (gtk_clist_focus_out): set CLIST_CHILD_HAS_FOCUS
+ flag, so we take the buttons into consideration upon the next focus
+ request.
+
+ * gtk/gtkcontainer.c (gtk_container_set_focus_child): fixed an
+ assertment.
+
Wed Dec 2 17:45:21 CST 1998 Shawn T. Amundson <amundson@gtk.org>
* gtk/gtkpixmap.c: Fixes for low-color displays and a slight
g_return_val_if_fail (event != NULL, FALSE);
GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS);
+ GTK_CLIST_SET_FLAG (widget, CLIST_CHILD_HAS_FOCUS);
+
gtk_widget_draw_focus (widget);
clist = GTK_CLIST (widget);
if (child)
{
g_return_if_fail (GTK_IS_WIDGET (child));
- GTK_CLIST_SET_FLAG (GTK_CLIST (container), CLIST_CHILD_HAS_FOCUS);
+ GTK_CLIST_SET_FLAG (container, CLIST_CHILD_HAS_FOCUS);
}
parent_class->set_focus_child (container, child);
}
void
-gtk_container_set_focus_child (GtkContainer *container,
- GtkWidget *widget)
+gtk_container_set_focus_child (GtkContainer *container,
+ GtkWidget *widget)
{
g_return_if_fail (container != NULL);
g_return_if_fail (GTK_IS_CONTAINER (container));
if (widget)
- g_return_if_fail (GTK_IS_WIDGET (container));
+ g_return_if_fail (GTK_IS_WIDGET (widget));
gtk_signal_emit (GTK_OBJECT (container), container_signals[SET_FOCUS_CHILD], widget);
}
* results:
*****************************************/
-void
-gtk_widget_grab_focus (GtkWidget *widget)
+static void
+reset_focus_recurse (GtkWidget *widget,
+ gpointer data)
{
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GTK_IS_WIDGET (widget));
+ if (GTK_IS_CONTAINER (widget))
+ {
+ GtkContainer *container;
+
+ container = GTK_CONTAINER (widget);
+ gtk_container_set_focus_child (container, NULL);
+
+ gtk_container_foreach (container,
+ reset_focus_recurse,
+ NULL);
+ }
+}
- if (GTK_WIDGET_CAN_FOCUS (widget))
+void
+gtk_widget_grab_focus (GtkWidget *focus_widget)
+{
+ g_return_if_fail (focus_widget != NULL);
+ g_return_if_fail (GTK_IS_WIDGET (focus_widget));
+
+ if (GTK_WIDGET_CAN_FOCUS (focus_widget))
{
- GtkWidget *parent;
- GtkWidget *child;
- GtkType window_type;
-
- window_type = gtk_window_get_type ();
- parent = widget->parent;
- child = widget;
+ GtkWidget *toplevel;
+ GtkWidget *widget;
- while (parent && !gtk_type_is_a (GTK_WIDGET_TYPE (parent), window_type))
+ /* clear the current focus setting, break if the current widget
+ * is the focus widget's parent, since containers above that will
+ * be set by the next loop.
+ */
+ toplevel = gtk_widget_get_toplevel (focus_widget);
+ if (GTK_IS_WINDOW (toplevel))
+ {
+ widget = GTK_WINDOW (toplevel)->focus_widget;
+
+ if (widget == focus_widget)
+ return;
+
+ if (widget)
+ {
+ while (widget->parent && widget->parent != focus_widget->parent)
+ {
+ widget = widget->parent;
+ gtk_container_set_focus_child (GTK_CONTAINER (widget), NULL);
+ }
+ }
+ }
+ else if (toplevel != focus_widget)
{
- gtk_container_set_focus_child (GTK_CONTAINER (parent), child);
- child = parent;
- parent = parent->parent;
+ /* gtk_widget_grab_focus() operates on a tree without window...
+ * actually, this is very questionable behaviour.
+ */
+
+ gtk_container_foreach (GTK_CONTAINER (toplevel),
+ reset_focus_recurse,
+ NULL);
}
-
- if (parent && gtk_type_is_a (GTK_WIDGET_TYPE (parent), window_type))
+
+ /* now propagate the new focus up the widget tree and finally
+ * set it on the window
+ */
+ widget = focus_widget;
+ while (widget->parent)
{
- gtk_container_set_focus_child (GTK_CONTAINER (parent), child);
- gtk_window_set_focus (GTK_WINDOW (parent), widget);
+ gtk_container_set_focus_child (GTK_CONTAINER (widget->parent), widget);
+ widget = widget->parent;
}
+ if (GTK_IS_WINDOW (widget))
+ gtk_window_set_focus (GTK_WINDOW (widget), focus_widget);
}
}
static gint gtk_window_client_event (GtkWidget *widget,
GdkEventClient *event);
static void gtk_window_check_resize (GtkContainer *container);
-static void gtk_real_window_set_focus (GtkWindow *window,
+static void gtk_window_real_set_focus (GtkWindow *window,
GtkWidget *focus);
static void gtk_window_move_resize (GtkWindow *window);
static void gtk_window_set_hints (GtkWidget *widget,
container_class->check_resize = gtk_window_check_resize;
- klass->set_focus = gtk_real_window_set_focus;
+ klass->set_focus = gtk_window_real_set_focus;
}
static void
gtk_window_set_focus (GtkWindow *window,
GtkWidget *focus)
{
- gtk_signal_emit (GTK_OBJECT (window), window_signals[SET_FOCUS], focus);
+ g_return_if_fail (window != NULL);
+ g_return_if_fail (GTK_IS_WINDOW (window));
+ if (focus)
+ {
+ g_return_if_fail (GTK_IS_WIDGET (focus));
+ g_return_if_fail (GTK_WIDGET_CAN_FOCUS (focus));
+ }
+
+ if (window->focus_widget != focus)
+ gtk_signal_emit (GTK_OBJECT (window), window_signals[SET_FOCUS], focus);
}
void
}
static void
-gtk_real_window_set_focus (GtkWindow *window,
+gtk_window_real_set_focus (GtkWindow *window,
GtkWidget *focus)
{
GdkEventFocus event;
g_return_if_fail (window != NULL);
g_return_if_fail (GTK_IS_WINDOW (window));
- if (focus && !GTK_WIDGET_CAN_FOCUS (focus))
- return;
-
- if (window->focus_widget != focus)
+ if (window->focus_widget)
{
- if (window->focus_widget)
- {
- event.type = GDK_FOCUS_CHANGE;
- event.window = window->focus_widget->window;
- event.in = FALSE;
-
- gtk_widget_event (window->focus_widget, (GdkEvent*) &event);
- }
-
- window->focus_widget = focus;
-
- if (window->focus_widget)
- {
- event.type = GDK_FOCUS_CHANGE;
- event.window = window->focus_widget->window;
- event.in = TRUE;
-
- gtk_widget_event (window->focus_widget, (GdkEvent*) &event);
- }
+ event.type = GDK_FOCUS_CHANGE;
+ event.window = window->focus_widget->window;
+ event.in = FALSE;
+
+ gtk_widget_event (window->focus_widget, (GdkEvent*) &event);
+ }
+
+ window->focus_widget = focus;
+
+ if (window->focus_widget)
+ {
+ event.type = GDK_FOCUS_CHANGE;
+ event.window = window->focus_widget->window;
+ event.in = TRUE;
+
+ gtk_widget_event (window->focus_widget, (GdkEvent*) &event);
}
}